#!/bin/bash
# @file: 
#	pxfix.sh
# @desc:
#	
# @Author:
#	codergege
# @Last Update:
#	2016-11-25 
# @usage:
#	 ./pxfix.sh
#	cd /usr/bin;sudo ln -sf /home/codergege/script/pxfix.sh pxfix.sh

# path
home=/home/codergege
pwdDir=$pwd

echo "Current resolution:"
xrandr
echo "-------------------------------------"
# New one modeline for 1440 * 900
#echo "New one modeline for 1440 * 900:"
#cvt 1440 900
cvt 1280 1024
echo "-------------------------------------"
# Create resolution using "xrandr --newmode" command
echo "Create resolution 1400 * 900:"
#xrandr --newmode "1440x900_60.00"  106.50  1440 1528 1672 1904  900 903 909 934 -hsync +vsync
xrandr --newmode "1280x1024_60.00"  109.00  1280 1368 1496 1712  1024 1027 1034 1063 -hsync +vsync 
echo "-------------------------------------"
# Add the resolution to monitor
echo "Add the resolution to monitor:"
xrandr --addmode DVI-0 "1280x1024_60.00"
echo "-------------------------------------"
# Apply the resolution
echo "Apply the resolution:"
xrandr --output DVI-0 --mode "1280x1024_60.00"
echo "-------------------------------------"
# Query current resolution again to determine the settings valid or not
echo "Current resolution after settings:"
xrandr
echo "-------------------------------------"

cd /usr/bin
if [ ! -f "pxfix.sh" ]; then
	sudo ln -sf /home/codergege/script/pxfix.sh pxfix.sh
fi
cd $pwdDir
